package com.zrh.jsd.service.studydemo.java8stream;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

// Function.identity() :相当于t -> t的静态方法。
public class IdentityTest {
    public static void main(String[] args) {
        Stream<String> stream = Stream.of("I", "love", "you", "too", "too");
        Map<String, Integer> map = stream.collect(Collectors.toMap(Function.identity(),
                String::length,
                (o1,o2) -> (Integer) o1,
                ConcurrentHashMap::new));
        System.out.println(map);
    }
}
